//
//  PDImageUtilCell.swift
//  ZYA
//
//  Created by 邱仙凯 on 2021/7/16.
//  Copyright © 2021 aowang. All rights reserved.
//

import UIKit
 
class PDImageUtilCell: UICollectionViewCell {
    
    var imgBtn:UIButton!
    var deleteBtn:UIButton!
    
    lazy var checkBtn:UIButton = {
        let v = UIButton()
        v.setTitle("点击识别", for: .normal)
        v.setTitleColor(.darkGray, for: .normal)
        return v
    }()
    lazy var realLab:UILabel = {
        let v = UILabel()
        v.text = "实际\n数量"
        v.font = UIFont.systemFont(ofSize: 12)
        v.numberOfLines = 2
        return v
    }()
    lazy var realText:UITextField = {
        let v = UITextField()
        v.backgroundColor = UIColor(kshex:"#f6f6f6")
        v.keyboardType = .numberPad
        v.textAlignment = .center
        v.font = UIFont.systemFont(ofSize: 12)
         v.placeholder = "输入数量"
        return v
    }()
    
    convenience required init(coder : NSCoder){
        self.init()
    }
    func showInputFunc(_ flag:Bool) {
        if flag {
            checkBtn.isHidden = false
            realLab.isHidden = false
            realText.isHidden = false
        } else {
            checkBtn.isHidden = true
            realLab.isHidden = true
            realText.isHidden = true
        }
    }

    override init(frame: CGRect) {
        super.init(frame: frame)
        self.initUtil()
    }
    
    func initUtil() {
        imgBtn = UIButton()
        imgBtn.setTitleColor(.darkGray, for: .normal)
        imgBtn.layer.cornerRadius = 6
        imgBtn.layer.masksToBounds = true
        imgBtn.titleLabel?.font = UIFont.systemFont(ofSize: 15)
        imgBtn.titleLabel?.numberOfLines = 0
        imgBtn.imageView?.contentMode = .scaleAspectFit
        imgBtn.imageView?.clipsToBounds = true
         self.addSubview(imgBtn)
        imgBtn.snp.makeConstraints { make in
            make.left.right.top.equalTo(self)
            make.bottom.equalTo(self).offset(-exHeight4Cell)
        }
        
        deleteBtn = UIButton(frame: CGRect(x:(self.ks_width - 25),y:0,width:25,height:25))
        deleteBtn.setBackgroundImage(UIImage(named:"ksphoto_delete"), for: .normal)
        self.addSubview(deleteBtn)
        
        self.addSubview(checkBtn)
        checkBtn.snp.makeConstraints { make in
            make.left.right.equalTo(self)
             make.height.equalTo(30)
            make.bottom.equalTo(self).offset(-35)
        }
        self.addSubview(realLab)
        realLab.snp.makeConstraints { make in
            make.left.equalTo(self)
            make.bottom.equalTo(self).offset(-1)
            make.width.equalTo(32)
        }
        self.addSubview(realText)
        realText.snp.makeConstraints { make in
            make.right.equalTo(self)
            make.bottom.equalTo(self).offset(-1)
            make.height.equalTo(30)
             make.left.equalTo(realLab.snp.right)
        }

        
        
    }
}
